<?php

namespace app\home\controller;

use app\common\controller\ApiController;
use app\home\service\ApiSiteService;
use think\Db;

class Apisite extends ApiController
{
    /**
    * 密码登录
    */
    public function pass_login()
    {
        $phone = input('phone');//手机号
        $password = input('password');//密码
        $result = ApiSiteService::pass_login($phone, $password);
        return json($result);
    }

    /**
    * 退出
    */
    public function logout()
    {
        $token = input('token');
        $result = ApiSiteService::logout($token);
        return json($result);
    }

    /**
    * 手机验证码登录
    */
    public function phone_login()
    {
        $phone = input('phone');
        $code = input('code');
        $result = ApiSiteService::phone_login($phone, $code);
        return json($result);
    }

    /**
    * 发送手机验证码
    */
    public function send_code()
    {
        $phone = input('phone');
        $result = ApiSiteService::send_code($phone);
        return json($result);
    }

    /**
    * 忘记密码
    */
    public function forget_pass()
    {
        $phone = input('phone');
        $code = input('code');
        $newpassword = input('newpassword');
        $repassword = input('repassword');
        $result = ApiSiteService::forget_pass($phone, $code, $newpassword, $repassword);
        return json($result);
    }

    /**
    * 修改密码
    */
    public function change_pass()
    {
        $token = input('token');
        $old_pass = input('old_pass');
        $new_pass = input('new_pass');
        $re_pass = input('re_pass');
        $result = ApiSiteService::change_pass($token, $old_pass, $new_pass, $re_pass);
        return json($result);
    }

    /**
    * 修改头像
    */
    public function upload_img()
    {
        $token = input('token');
        $file = request()->file('file');
        $result = ApiSiteService::upload_img($token, $file);
        return json($result);
    }

    /**
    * 身份确认列表
    */
    public function identity_list()
    {
        $token = input('token');
        $result = ApiSiteService::identity_list($token);
        return json($result);
    }

    /**
    * 提车确认列表
    */
    public function fetch_list()
    {
        $token = input('token');
        $result = ApiSiteService::fetch_list($token);
        return json($result);
    }

    /**
    * 退车确认列表
    */
    public function back_list()
    {
        $token = input('token');
        $result = ApiSiteService::back_list($token);
        return json($result);
    }

    /**
    * 身份认证
    */
    public function identity_affirm()
    {
        $token = input('token');
        $member_id = input('member_id');
        $type = input('type');
        $result = ApiSiteService::identity_affirm($token, $member_id, $type);
        return json($result);
    }

    /**
    * 提车确认
    */
    public function fetch_affirm()
    {
        $token = input('token');
        $order_id = input('order_id');
        $type = input('type');
        $result = ApiSiteService::fetch_affirm($token, $order_id, $type);
        return json($result);
    }

    /**
    * 退车确认
    */
    public function back_affirm()
    {
        $token = input('token');
        $order_id = input('order_id');
        $type = input('type');
        $result = ApiSiteService::back_affirm($token, $order_id, $type);
        return json($result);
    }

    /**
    * 订单列表
    */
    public function order_list()
    {
        $token = input('token');
        $page = input('page');
        $result = ApiSiteService::order_list($token, $page);
        return json($result);
    }

    /**
    * 订单详情
    */
    public function order_detail()
    {
        $token = input('token');
        $order_id = input('order_id');
        $result = ApiSiteService::order_detail($token, $order_id);
        return json($result);
    }

    /**
    * 完成
    */
    public function change_order()
    {
        $order_id = input('order_id');
        $result = ApiSiteService::change_order($order_id);
        return json($result);
    }

}